﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for RoleData
/// </summary>
public class RoleData
{
	public RoleData()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool add(RoleEntities item)
    {
        bool flat = false;
        string[] paramater = {"@name" };
        string[] values = {item._name };
        if (Database.getExecProcedure("InsertRole",paramater,values)>0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool edit(RoleEntities item)
    {
        bool flat = false;
        string[] paramater = { "@id", "@name" };
        string[] values = {item._id.ToString(), item._name };
        if (Database.getExecProcedure("EditRole", paramater, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool delete(int id)
    {
        bool flat = false;
        string[] paramater = { "@id" };
        string[] values = { id.ToString()};
        if (Database.getExecProcedure("DeleteRole", paramater, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public DataTable getRole(int id)
    {
        return Database.getTable("exec GetRole '" + id.ToString() + "'");
    }
}
